<?php

class reviewsave{
public function index(){
$dp_data = array();
$dp_data['title'] = addslashes(htmlspecialchars($GLOBALS['request']['title']));
$dp_data['content'] = addslashes(htmlspecialchars($GLOBALS['request']['content']));
$dp_data['create_time'] = get_gmtime();
$dp_data['point'] = intval($GLOBALS['request']['point']);
$dp_data['user_id'] = intval($GLOBALS['request']['user_id']);
$dp_data['supplier_location_id'] = intval($GLOBALS['request']['supplier_id']);
$dp_data['status'] = 1;
if($dp_data['user_id']<=0)
{
$root['info']='请先登入';
output($root);
}
$GLOBALS['db']->autoExecute(DB_PREFIX.'supplier_location_dp',$dp_data ,'INSERT');
$dp_id = $GLOBALS['db']->insert_id();
if($dp_id>0)
{
increase_user_active(intval($dp_data['user_id']),'发表了一则商户点评');
$GLOBALS['db']->query('update '.DB_PREFIX.'user set dp_count = dp_count + 1 where id = '.intval($dp_data['user_id']));
$point_Group = $GLOBALS['request']['point_group'];
$root['point_group']=$point_Group;
foreach($point_Group as $group_id =>$point)
{
$point_data = array();
$point_data['group_id'] = $group_id;
$point_data['dp_id'] = $dp_id;
$point_data['supplier_location_id'] = intval($dp_data['supplier_location_id'] );
$point_data['point'] = intval($point);
$GLOBALS['db']->autoExecute(DB_PREFIX.'supplier_location_dp_point_result',$point_data,'INSERT');
}
$supplier_info = $GLOBALS['db']->getRow('select name,id,new_dp_count_time from '.DB_PREFIX.'supplier_location where id = '.$dp_data['supplier_location_id']);
$title = '对'.$supplier_info['name'].'发表了点评';
$url_route = array(
'rel_app_index'=>'store',
'rel_route'=>'view',
'rel_param'=>'id='.$supplier_info['id']
);
$tid = insert_topic($dp_data['content'],$title,'slocationcomment',$group='',$relay_id = 0,$fav_id = 0,$group_data = '',$attach_list=array(),$url_route);
if($tid)
{
$GLOBALS['db']->query('update '.DB_PREFIX."topic set source_name = '网站' where id = ".intval($tid));
}
syn_supplier_locationcount($supplier_info);
$cache_id  = md5('store'.'view'.$supplier_info['id']);
$GLOBALS['tmpl']->clear_cache('store_view.html',$cache_id);
$root['info'] = 1;
}
else{
$root['info'] = '数据库异常，提交失败';
}
output($root);
}
}

?>